# 测试字符串格式化
# print方法默认会换行打印，禁止换行需要添加 end='' 标识符参数
name = 'drzhang'
age = 25

print('{0} is {1} years old'.format(name, age))
print('{0:.3}'.format(1.0 / 3))
print('{0:_^14}'.format('hello'))
print('a', end='')
print('{0:.3}'.format(1.0 / 3))

# 三引号保证换行
print('''this is 
 a new 
 world''')

# 常用运算符
# lambda; if - else; or; and; not x;
# int; not in; is; is not;
# |; ^; &; <<; >>;
# ** 乘方
#

a = 1
b = 22
c = 10
d = 6

result = 0

if result < a:
    print("< a")
elif result < d:
    print("<d")
elif result < c:
    print("<c")
elif result < d:
    print("<d")
else:
    print("larger than max")

number = 20;
# count = input('enter your age: ')
# print('your age is {}'.format(count))


running = True
running = False
while running:
    guess = int(input("enter your integer: "))

    if guess == number:
        print("congratulation,you guess it")
        running = False
    elif guess < number:
        print("No, it is a littel higher than that")
    else:
        print("No, it is a litter lower than that")

# while 循环跳出循环时执行else语句
else:
    print("the while loop is over")

print("done")

for i in range(0, 6):
    if i == 2:
        continue
    print(i)


def say_hello():
    # 函数快执行区域
    print(" hello python")


def print_max(a, b):
    if a > b:
        print("the larger is {}".format(a))
    elif a < b:
        print("the larger is {}".format(b))
    else:
        print("they are equals")


x = 50;


def func():
    global x  # global 关键字表示在函数体内对全局变量进行更改
    print('x is ', x)
    x = 2
    print('changed global x is ', x)


func()
print('value of x is ', x)


def say(message, times=1):
    print(message * times)


say('hello')
say('hello', 5)



# print_max(2, 5)

# 函数结束

# say_hello()
